// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_activity;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceGroup;
import com.nnee.p_b.p_a.cls_d;
import com.nnee.p_fk.cls_PreferenceActivityEx;
import com.nnee.p_pr.p_app.cls_PrisApp;
import com.nnee.p_pr.p_atom.cls_u;
import com.nnee.p_pr.p_c.cls_c;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;

// Referenced classes of package com.nnee.p_pr.p_activity:
//            fv, df, dd, fu

public class cls_OfflineDownloadMgrActivity extends cls_PreferenceActivityEx
    implements android.preference.Preference.OnPreferenceChangeListener
{

    public cls_OfflineDownloadMgrActivity()
    {
        g = new ArrayList(2);
        h = new ArrayList(2);
        i = null;
        j = new cls_fv(this);
    }

    private void a()
    {
        ArrayList arraylist = new ArrayList(2);
        Iterator iterator = h.iterator();
        do
        {
            if(!iterator.hasNext())
                break;
            cls_df df1 = (cls_df)iterator.next();
            if(a(df1, g))
            {
                String s = cls_df.a(df1);
                boolean flag;
                if(!cls_df.b(df1))
                    flag = true;
                else
                    flag = false;
                arraylist.add(new cls_dd(this, s, flag));
            }
        } while(true);
        cls_PrisApp.a().a(arraylist);
    }

    public static void a(Context context)
    {
        context.startActivity(new Intent(context, com.nnee.p_pr.p_activity.cls_OfflineDownloadMgrActivity.class));
    }

    static void a(cls_OfflineDownloadMgrActivity offlinedownloadmgractivity, boolean flag)
    {
        offlinedownloadmgractivity.b(flag);
    }

    private void a(String s, boolean flag)
    {
        if(g != null) {
        	Iterator iterator = g.iterator();
            cls_df df1=null;
            do
            {
                if(!iterator.hasNext())
                    continue; /* Loop/switch isn't completed */
                df1 = (cls_df)iterator.next();
            } while(!cls_df.a(df1).equals(s));
            cls_df.a(df1, flag);
        }
    }

    private void a(boolean flag)
    {
        if(g != null)
        {
            Iterator iterator = g.iterator();
            while(iterator.hasNext()) 
                cls_df.a((cls_df)iterator.next(), flag);
        }
    }

    private boolean a(cls_df df1, ArrayList arraylist)
    {
        boolean flag = false;
        if(df1 != null && arraylist != null) {
        	Iterator iterator = arraylist.iterator();
            cls_df df2=null;
            do
            {
                if(!iterator.hasNext())
                    continue; /* Loop/switch isn't completed */
                df2 = (cls_df)iterator.next();
            } while(!cls_df.a(df1).equals(cls_df.a(df2)));
            boolean flag1;
            if(cls_df.b(df1) != cls_df.b(df2))
                flag1 = true;
            else
                flag1 = flag;
            flag = flag1;
        }
 
        return flag;
 
    }

    public static Intent b(Context context)
    {
        return new Intent(context, com.nnee.p_pr.p_activity.cls_OfflineDownloadMgrActivity.class);
    }

    private void b()
    {
        e();
        c();
    }

    private void b(boolean flag)
    {
        for(int l = 0; l < f.getPreferenceCount(); l++)
        {
            Preference preference = f.getPreference(l);
            if(!preference.getKey().equals("offline_donwload_mgr_setting_select_all_source"))
            {
                ((CheckBoxPreference)preference).setChecked(flag);
                i.setProgress(l);
            }
        }

        if(flag)
        {
            ArrayList arraylist = i();
            com.nnee.p_pr.p_c.cls_c.a(this, com.nnee.p_b.p_a.cls_d.h().c(), arraylist);
        } else
        {
            com.nnee.p_pr.p_c.cls_c.d(this, com.nnee.p_b.p_a.cls_d.h().c());
        }
        a(flag);
        k();
    }

    private void c()
    {
        boolean flag = false;
        f.removeAll();
        f.addPreference(e);
        boolean flag1 = true;
        CheckBoxPreference checkboxpreference;
        for(Iterator iterator = g.iterator(); iterator.hasNext(); f.addPreference(checkboxpreference))
        {
            cls_df df1 = (cls_df)iterator.next();
            checkboxpreference = new CheckBoxPreference(this);
            checkboxpreference.setTitle(com.nnee.p_pr.p_activity.cls_df.c(df1));
            checkboxpreference.setPersistent(flag);
            if(flag1 && !cls_df.b(df1))
                flag1 = flag;
            checkboxpreference.setKey(cls_df.a(df1));
            checkboxpreference.setOnPreferenceChangeListener(this);
            checkboxpreference.setChecked(cls_df.b(df1));
        }

        if(g.size() != 0)
            flag = flag1;
        e.setChecked(flag);
    }

    private void e()
    {
        g.clear();
        LinkedList linkedlist = com.nnee.p_pr.p_c.cls_c.a(this, com.nnee.p_b.p_a.cls_d.h().c(), false);
        if(linkedlist != null)
        {
            Iterator iterator = linkedlist.iterator();
            while(iterator.hasNext()) 
            {
                cls_u u1 = (cls_u)iterator.next();
                String s = u1.U();
                String s1 = u1.V();
                boolean flag = com.nnee.p_pr.p_c.cls_c.c(this, com.nnee.p_b.p_a.cls_d.h().c(), u1.V());
                g.add(new cls_df(this, s, s1, flag));
                h.add(new cls_df(this, s, s1, flag));
            }
        }
    }

    private void g()
    {
        e = (CheckBoxPreference)findPreference("offline_donwload_mgr_setting_select_all_source");
        e.setOnPreferenceChangeListener(this);
        f = (PreferenceGroup)findPreference("offline_donwload_mgr_setting_source_list");
    }

    private boolean h()
    {boolean flag = false;
        if(g != null) {
        	for(Iterator iterator = g.iterator(); iterator.hasNext();)
                if(!cls_df.b((cls_df)iterator.next()))
                {
                    flag = false;
                    continue; /* Loop/switch isn't completed */
                }

            flag = true;
            
        } 
        return flag;
 
    }

    private ArrayList i()
    {
        if(g == null)
            throw new RuntimeException("mSource is null");
        ArrayList arraylist = new ArrayList();
        Iterator iterator = g.iterator();
        do
        {
            if(!iterator.hasNext())
                break;
            cls_df df1 = (cls_df)iterator.next();
            if(!cls_df.b(df1))
                arraylist.add(cls_df.a(df1));
        } while(true);
        return arraylist;
    }

    private void j()
    {
        i = ProgressDialog.show(this, null, getText(0x7f0a01f1), true, true);
        i.setIndeterminate(false);
        i.setMax(f.getPreferenceCount());
    }

    private void k()
    {
        if(i != null)
        {
            i.dismiss();
            i = null;
        }
    }

    public void onCreate(Bundle bundle)
    {
        super.onCreate(bundle);
        addPreferencesFromResource(0x7f050001);
        g();
        b();
    }

    protected void onDestroy()
    {
        a();
        super.onDestroy();
        if(g != null)
        {
            g.clear();
            g = null;
        }
        if(h != null)
        {
            h.clear();
            h = null;
        }
        if(f != null)
        {
            f.removeAll();
            f = null;
        }
        System.gc();
    }

    public boolean onPreferenceChange(Preference preference, Object obj)
    {
        boolean flag1;
        if(preference.getKey().equals("offline_donwload_mgr_setting_select_all_source"))
        {
            j();
            boolean flag2 = ((Boolean)obj).booleanValue();
            j.postDelayed(new cls_fu(this, flag2), 300L);
            flag1 = true;
        } else
        {
            String s = preference.getKey();
            boolean flag = ((Boolean)obj).booleanValue();
            ((CheckBoxPreference)preference).setChecked(flag);
            com.nnee.p_pr.p_c.cls_c.a(this, com.nnee.p_b.p_a.cls_d.h().c(), s, flag);
            String s1 = ((CheckBoxPreference)preference).getTitle().toString();
            if(flag)
                com.nnee.p_pr.p_d.cls_c.a(f(), 651, s1);
            else
                com.nnee.p_pr.p_d.cls_c.a(f(), 652, s1);
            a(s, flag);
            if(!flag)
                e.setChecked(false);
            else
                e.setChecked(h());
            flag1 = false;
        }
        return flag1;
    }

    private static final String a = "offline_donwload_mgr_setting_select_all_source";
    private static final String b = "offline_donwload_mgr_setting_source_list";
    private static final String c = "OfflineDownloadMgrActivity";
    private static final int d=0;
    private CheckBoxPreference e;
    private PreferenceGroup f;
    private ArrayList g;
    private ArrayList h;
    private ProgressDialog i;
    private Handler j;
}
